package com.libservice.webviewmessageservice

import com.libbase.datarepository.DataRepositoryManager
import com.libservice.ServiceManager

class WebViewMessageService : WebViewMessageServiceInterface {

    override fun webViewMessage(messageId: String, params: Map<String, Any>?) {
        when (messageId) {
            "refreshProjectGroup" -> {
                val itemId = if (params?.get("itemId") is Int) {
                    (params["itemId"]).toString()
                } else {
                    params?.get("itemId") as String
                }
                val value = params["value"]
                DataRepositoryManager.instance.repository("ProjectGroupRepository")
                    ?.updateItemValue(itemId, "projectCount", value)
            }

            "exportData" -> {
                ServiceManager.instance.routerService.present(
                    "app://page/userCenter/export", params, false
                ) { _, _ ->
                }
            }

            else -> {}
        }
    }
}